package edu.ua.Team_Industry;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

public class InputInfo extends Activity{
	
	private String type1;
	private String type2;
	private String type3;
	private String type4;
	private String type5;
	int tagType;
	
	public void setTagTypes(String str1, String str2, String str3, String str4, String str5) {
		type1=str1;
		type2=str2;
		type3=str3;
		type4=str4;
		type5=str5;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	setContentView(R.layout.tag_info);
	
	type1 = "Emergency";
	type2 = "Aid";
	type3 = "Obstruction";
	type4 = "Damage";
	type5 = "Other";
	
	final EditText input = (EditText) findViewById(R.id.descr_edit);
	//final EditText url = (EditText) findViewById(R.id.picURL);
	
	String[] items = new String[] {type1, type2, type3, type4, type5};
	Spinner spinner = (Spinner) findViewById(R.id.tagCombo);
	ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
	            android.R.layout.simple_spinner_item, items);
	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	spinner.setAdapter(adapter);
	spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
	
	

	final Button btn = (Button) findViewById(R.id.btnOK);
	btn.setOnClickListener(new OnClickListener() {
	    public void onClick(View v) {
	    	String desc = input.getText().toString();
	    	//String picURL = url.getText().toString();
	    	Intent myIntent = new Intent();
	    	myIntent.putExtra("DESCRIPTION", desc);
	    	//myIntent.putExtra("URL", picURL);
	    	myIntent.putExtra("TAG_TYPE", tagType);
	    	setResult(RESULT_OK, myIntent);
			finish();
	    }
	});
}
	public class MyOnItemSelectedListener implements OnItemSelectedListener {

	    public void onItemSelected(AdapterView<?> parent,
	        View view, int pos, long id) {
	      tagType = (pos)+1;
	    }

	    public void onNothingSelected(AdapterView parent) {
	      // Do nothing.
	    }
	}
}
